﻿-----------------------------------------------------------------------------------
Changelog
-----------------------------------------------------------------------------------
- v1.5	29/07/2013
	* Added a (rudimentary) progress bar for the "Generate batch" option.
	* There was a way to crash the "Jump to" function by pasting non-numeric text in its field.
	  Now the application checks if the field is a number.
	* Now, "jumping" to a non-existing dialogue (like 50 when you only have 10) will take you
	  to the last existing dialogue (10 in this example).
	* Fixed the titles of the file browser for several functions (they were confusing or
	  shared the titles with another function)
	   
- v1.4c 10/04/2013
	* Fixed the "-1" button. It wasn't behaving properly and could hang the applet.

- v1.4b 05/04/2013
	* Same error from v1.4a (with saving after creating a new file) applied after using "Create file
	  from folder". Now it's fixed.

- v1.4a 30/03/2013
	* In previous versions, if you opened a file, then created a new file (File->New) and saved that
	  new file (File->Save), it would overwrite the previously open file. Now that's fixed (if you
	  follow the previous example, once you click on File->Save, you'll get the same effect as if
	  you had clicked File->Save as...)
	* Some text fields in the UI would be redimensioned if you wrote a big amount of text in them
	  (you would only notice that if you loaded the dialogue again or minimized and maximized the
	  tool). They should be fixed now.

- v1.4	29/03/2013
	* Added the "create from folder" option to the File menu. Works like the Texture Organizer, but doesn't save the file,
	  it updates your working file instead (which you can save).
	* Added the "generate batch in destination folder" to the Generate... menu. It lets you open a txt file containing the
	  relative filenames of dialogue files and generate their dialogue textures.
	* Added an example of batch file to the zip.
	* Improved the preview window. Now pressing the backspace or delete keys won't generate strange graphics. There's other
	  cases that will, though (CTRL+V or overwriting text, for example).
	
- v1.3a 21/03/2013
	* Fixed problem with backspacing showing weird characters in preview window.
	* Fixed problem with editing in the middle of lines (the new character was shown at the end of the line in the preview).
	* Switching an existing dialogue from lower to upper (or the other way around) now cleans its previous location and loads the previous dialogue if that was its place.
	* Adjusted the proportions of the preview window to match the game's displayed window.
	* Moved the preview window's default position slightly to the right, to avoid the main window being over it.
	* Fixed a bug when selecting "New" in the menu. It didn't write "New file" in the frame's title.
	
- v1.3	19/03/2013
	* Added Preview window and Preview toggle button.
	* Gave the applet an icon.
	* Extended the "Grab from folder" function to accept battle dialogue textures as well.
	* Improved navigation of the UI. Now, pressing TAB while in the Speaker field will take you to Line 1.

- v1.2	18/03/2013
	* Added the "Grab from folder" button in the "Texture generation" panel.
	
- v1.1	18/03/2013
	* Added support for up to 4 sets of filenames for the dialogues.
	* Changed "Action" menu for "Generate.." menu. Now it has options to generate specific sets or all.
	* Improved the look of the menus slightly.
	* Added a subfolder field for each dialogue.
	* Added important note to this document.

- v1.0	16/03/2013
	* First release.

-----------------------------------------------------------------------------------
Super Robot Taisen GC Dialogue Editor version 1.0 by Dashman (ulricvonmesnar@hotmail.com)
Compiled: March 2013
-----------------------------------------------------------------------------------

This utility is meant to help in the translation of the game Super Robot Taisen GC for 
the Nintendo Gamecube by making it easy to create custom dialogue textures for use in
the Nintendo Gamecube and Nintendo Wii emulator Dolphin.

Since this tool is built over a feature of the Dolphin emulator, it is not possible to
use it to produce a translation for use in the real hardware. If that's what you're
after, you may stop reading here.

The application lets you create, edit, save and open text files containing a number of
dialogue boxes corresponding to the game's own, as well as a one-click way to generate
said dialogue boxes in the form of properly formatted textures to be inserted in the game
via the emulator. Writing text and clicking buttons is much easier than edit images and
much more easier to maintain, which makes this tool quite useful.

As it is programmed in Java, the application should be cross-platform, but since the
texture rendering feature uses a Microsoft font (MS UI Gothic), it is possible for
textures generated on an OS other than a Windows platform to look different or even not
be generated at all.

In this document I'll try to explain the "texture-swapping" technique that makes this kind
of tool useful, how to use the Dolphin emulator specifically for this technique, the way 
dialogue boxes work in the Super Robot Taisen / Wars GC game (SRW GC from now on) and of 
course the way to use this application, as well as what I consider can be some useful tips 
to make the translation easier.

-----------------------------------------------------------------------------------
!!. IMPORTANT NOTE.
-----------------------------------------------------------------------------------

At the time of writing this document, the only version of Dolphin recommended to use this
tool with is 3.0 (no revision). There shouldn't be any difference between x86 and x64 for
the sake of this tool, but to be safe, use the x64 version. Apparently, the dumping of
textures has become inconsistent after v3.0, so that different versions of the emulator
past that one produce different texture names, sometimes even creating several different
ones in the same machine. Make sure you're working with Dolphin 3.0 before using this.
If it's called "Dolphin 3.0-792 dirty" it's NOT 3.0, it's a revision.

-----------------------------------------------------------------------------------
0. Quick guide.
-----------------------------------------------------------------------------------

You don't want to read this whole document, or at least not more than once. So here's a quick
summary of what to do to translate a dialogue:

	1) Run Dolphin. Play the game to the point where you find something you want to translate.
	2) STOP (that's you, not the emulator)
	3) Go to Options->Configure graphics->Advanced in the emulator's menu. Activate "Dump textures".
		Accept.
	4) Check the folder /User/Dump/Textures/GRWJD9 (subfolders in Dolphin's folder) and see
		that the textures you want have been dumped. They usually end with "_9.png". 
		They're 1024 x 128 pixels, fat and short, easy to spot on preview.
	5) Open this tool. Write down the names of the 2 or 3 versions of the texture (white, gray 
		and yellow text) in the last panel if you have them all located. Find at least one.
	6) Click the Browse button and select a subfolder of /User/Load/Textures/GRWJD9 
		(if this folder doesn't exist, create it)
	7) Write the translation of the dialogue in the Dialogue content panel. "Speaker" is the character
		speaking. Lines have no limit, but if you write too much it will go over the character face
		or even out of the screen. If the dialogue appears on the upper part of the screen, select
		"Upper dialogue", leave it on "Lower dialogue" otherwise.
	8) Click on "GENERATE TEXTURES". If everything goes well, you'll get a message for every
		succesfully generated texture. You can check the folder you selected with Browse and see them
		for yourself.
	9) Go back to Options->Configure graphics->Advanced in Dolphin. Uncheck "Dump textures" and check
		"Load custom textures". Accept.
	10) Check the game screen. If the dialogue you created hasn't changed, save state (SHIFT + F1, for
		example) and load state (F1, if you did the previous example).
	11) In the tool, click on "+1" and then on the ">>" button. You'll be in a new dialogue. Save the
		file if you want (File->Save or File->Save as...).
	12) Go back to step 1.
	
* This is assuming you're starting a new file. Naturally, you can navigate the messages however you want.

Say you are not a translator, but just downloaded this applet and a bunch of text files
that somebody has assured you they're the translation of this game. Here's what you
have to do:

	1) Open this tool.
	2) Go to File->Open... and select one of the text files (or the only one) you've got.
		If everything goes well, some fields will be changed in the UI and some buttons
		will become active. If an error occurs, you'll get a warning message.
	3) Click the Browse button in the lower right part of the application and select the
		folder /User/Load/Textures/GRWJD9 (or one of its subfolders) inside the folder 
		where you have the Dolphin emulator. The folder GRWJD9 most probably doesn't
		exist, so create it if that's the case.
	4) Select "Action->Generate ALL dialogue textures". This will create the textures
		containing the dialogues of this file in the folder you selected in step 3).
		If everything goes well, a pop-up window will tell you how many textures
		were generated. If it says no textures were generated, the file may be
		wrong or you have no permission to write in that folder (unlikely).
	5) You can close the tool now and open Dolphin.
	6) Go to Options->Configure graphics->Advanced and activate the "Load custom textures" option.
		Make sure you're using Direct 3D 9 or 11 before activating said option. Accept.
	7) Play the game. When you reach the translated part (hopefully you know what part
		you were translating when you opened the file) you will notice the difference.

Now on to the LONG and BORING stuff. Be warned!

-----------------------------------------------------------------------------------
1. Loading custom textures in Dolphin.
-----------------------------------------------------------------------------------

Dolphin features an option for inserting your own textures in any game you want. This is not
a new trick though, as N64 emulators back them sported this too and some user communities 
exploited it to use high definition (HD) textures in its games. Altering the look and feel
of any game that runs on this emulator is possible by these means, and obviously one of
them is turn every Japanese textbox into a fairly more understandable English one.

How does this happen, exactly? Well, more or less it goes like this: everything that is "shown"
in a game that is not a 3D model has to be stored as an image, that is, a texture. Yes, numbers and
characters are included; if you see it with your eyes and it's not a 3D shape, it's a texture.
Please note that 3D shapes have textures "painted" on them. Anyway, wherever those textures are
stored right before being shown is not clear to me, but by selecting an internal option, 
every texture that enters such storage are will get copied into a folder of your OS. By
activating yet another option, the emulator will use any textures you give it instead of
the ones it was meant to use, provided the new textures are named exactly like the ones
they are replacing (and are located in the proper folder).

So the methodology could be summarized as:
1) Enable "dump textures"
2) Find the textures you want to change
3) Edit said textures
4) Save the edited textures in the folder meant for loading textures
5) Enable "load custom textures"
6) Play the game with the new textures

Step 1) is achieved by ticking "Dump textures" option. Go to Options->Configure graphics->Advanced.
From that moment on, all shown textures will be stored in /User/Dump/Textures/<game ID>
(in the case of SRW GC, the game ID is GRWJD9). Beware that the folder can become quite full
if you play for a while with this option active. WARNING: don't have it active during videos,
every video frame seems to count as a texture. If you're using any of the Direct 3D plugins
of Dolphin (the default plugin), the textures will be stored as PNG, but if you're using OpenGL 
they'll be stored as TIFF. Don't use OpenGL, this tool only works with PNG.

REMEMBER: What you see is what you get. The only textures dumped will be the ones shown on screen.

After step 1), you'll have to find the textures you want to edit in /User/Dump/Textures/GRWJD9.
Step 2) is much easier if you do the following: play normally until you reach the point
where the texture you want is shown; activate "dump textures"; find the texture you want among
a relatively small number of textures; deactivate "dump textures" and continue playing. Using
savestates is heavily recommended, specially if you want to see what the results of the editing
later. In Dolphin, SHIFT + any function key from F1 to F8 saves a state. Pressing only the function
key loads the specific state (SHIFT + F1 saves state 1, F1 loads state 1 and so on).

Step 3) is what this tool is about. Explained later.

Once you have your edited textures, save them in /User/Load/Textures/GRWJD9 with THE SAME NAME
THEY HAD when you found them in the Dump folder. You can put them in any folder though, as
long as it is a subfolder of GRWJD9 Dolphin will recognize it. That's step 4).

But for Dolphin to recognize it, you have to activate the "Load custom textures" option, which is
right next to the "Dump textures" option you activated in step 1). That makes step 5).

And finally you can play with your custom textures. From my experience, "Load custom textures"
doesn't work if you have "Dump textures" active at the same time in Direct 3D 11, but
there's cases of people having both options working at the same time in Direct 3D 9.
I would recomend deactivating "Dump textures" any time you don't want to grab anything, anyway.

Boy, that was long, sorry.


-----------------------------------------------------------------------------------
2. Dialogue boxes in SRW GC and how do they work.
-----------------------------------------------------------------------------------

If you've played any SRW game, you're familiar with the way the dialogues are presented.
When a character is talking, a box appears on the upper or lower end of the screen, showing
the character's portrait, their name and what they're saying. Luckily enough, in SRW GC,
the character's name and their dialogue are stored as a unique texture before displaying
on screen, which we can find, edit and replace.

There's some peculiarities that must me noted though. There's actually three different kind of
dialogue sections in the game:
 -- Intermission dialogue: These are the conversations that happen before and after the
	missions. Can have upper and lower dialogue boxes at the same time, with character
	portraits shown in opposite sides (upper is shown to the left, lower to the right). There is
	an active or "current" dialogue box with written text in white, showing who's talking
	at the moment and tipically the remaining dialogue box shows what another character
	said before the current character started talking. That inactive or "recent" dialogue box
	has its text displayed in gray. At any time during a "talking scene", you can press
	the B button in the Gamecube controller to go back in the conversation, seeing "past"
	dialogue displayed in yellow. All three "current", "recent" and "past" dialogues can
	be edited with this tool (but you have to find them first).
	
 -- Mission / Event dialogue: During a mission, pilots talk. A LOT. Facing the end of the world
	doesn't make them less chatty. Anyway, these dialogue boxes are almost the same as the
	ones in the intermission dialogue, but simpler. The only box shown this time is the lower
	one, which means there is no "recent" dialogue to look for.
	
 -- Battle dialogue: When in a battle sequence, the pilots will say things (with voices) and
	the battle dialogue box will show subtitles of what they say. These subtitles can't be
	translated with this tool, since the game shows each character individually.
	
From all this, you can understand that there are 3 different textures of each dialogue ("current",
"recent" and "past") that has to be found and identified. The only things we need to translate
them are their respective names, this tool and knowing what is written in them, obviously.

These textures are quite small and tricky to identify sometimes. For example, since "current" 
dialogues are white characters over transparent background, if you open them with the default 
Windows Image & Fax Viewer, you will have a really hard time seeing anything. Better use a program 
that let's you visualize the alpha of the pictures (like GIMP or Photoshop, but probably ACD See 
and Irfant View as well) so that you can see other than white over white.


-----------------------------------------------------------------------------------
3. Using the editor.
-----------------------------------------------------------------------------------

If you have Java (or the Java Runtime Environment) installed in your computer, you can double-click
the SRW_GC_Dialogue_Editor_v1.0.jar file and it will start. Or you can launch it via the 
command line with the order

java -jar SRW_GC_Dialogue_Editor_v1.0.jar

while in the same directory. This last method can display some information on the command line
in case of some errors, so use it if you suspect something is going wrong (and email me
telling me what error you got and how, if you please, so that I can fix it).

If you don't have Java installed, well, you NEED it to run this. Go to java.com and download it.

You'll notice that the User Interface (UI) has a menu bar and three panels that I've tried
to make as self-explanatory as I could, but let me explain a bit how they work, from top to bottom.

 -- The menu bar: You'll find the File submenu, the Action submenu and the ? submenu here. 
	The last one only has the classic "About" message, which is unimportant, but the first one 
	has some implications worth explaining. You see, this tool works with files that hold the contents of
	several dialogue boxes. It has been made this way so that, for example, you could store
	all the conversations that happen before the 1st mission in a file ("01 - premission.txt",
	for example), the ones during the 1st mission in another file ("01 - mission.txt") and in
	another, the ones after the mission ("01 - postmission.txt"). Easier to organize than
	dealing individually with each dialogue, easier to navigate than having a unique script
	file and sharing the text files is way easier than sending the bunch of generated textures.
	Anyway, this works with files and the options in the "File" submenu let you start a new one,
	save the current one, open a pre-existing one or exit the application. Just keep in mind
	that THERE IS NO UNDO OR REDO options. Be careful and save often. 
	
	And finally, you may have been wondering about the "Action" submenu. This one only has an option:
	"Generate ALL dialogue textures". If the name isn't clear enough, I'll explain: this option let's you
	generate all dialogue textures from the dialogues contained in the file that are
	properly formatted (that is, they have a Speaker, something to say and filenames defined).
	This option is great in case you download a .txt file from a person who has been translating
	a part of the game. You just have to open the .txt file, choose the directory where you
	want to create the textures, and select this option. BAM! You got a whole new chunk
	of the game translated in 3 clicks. Cool, right?
	* CHANGED IN v1.1: The "Action" submenu is now called "Generate..." and has four new options,
	each one for generating all the textures of one of the four available sets introduced in
	this version. Since the problem these sets were addressing is technically solved, these
	options can be flatly ignored.
	
 -- The Navigation panel: When you open the applet, you will start with one empty dialogue. You
	can add more dialogues as you need them with the "+1" button, or sustract them with the "-1"
	button. Once you have more than one dialogue, you'll be able to move through them with
	the arrow buttons (previous and next) or just jump directly to the dialogue number X. At
	every moment, you'll be able to see the number of the current dialogue and the total number
	of dialogues in the file. If you push the "-1" button while on the last dialogue, you'll be
	sent to the previous dialogue, which will be the new last one.
	
 -- The Dialogue content panel: Here is where you write the translated content of the dialogue.
	As you can see, there's a text field to write the name of the speaker (that is the character),
	four text fields for each line that can be written in the dialogue and a couple of radio buttons
	to indicate if the dialogue is supposed to be on the upper or lower part of the screen. This
	distinction is necessary because the upper dialogues have to be drawn displaced to the right,
	so that they're not written over the face of the speaker. The fields for the lines are not
	capped, that is, you have to be careful of not writing too much in each line, or you'll
	write over a person's face or even outside the screen.
	
 -- The Texture generation panel: Here is where you write the names of the textures you want to
	generate, which obviously have to match their dumped equivalents. When the button "GENERATE
	TEXTURES" is pushed, only those textures selected and with a name written in their respective
	text field will be created. If you didn't write the name of the speaker or any line, you'll
	get a warning. If the destination folder hasn't been selected, the textures will be generated
	in the same folder where the application is. Otherwise, they'll be generated in whatever folder
	you chose (a subfolder of /User/Load/Textures/GRWJD9, for example). You should get an information
	pop-up for each texture successfully generated. The names of the texture files are stored
	along the dialogue data, so you can save the generation of them for another moment once you have
	all of them (or have changed the dialogue).
	
	* ADDED IN v1.1: The texture generation panel has now support for up to four different sets
	of filenames. This feature was conceived with the problem of the inconsistent texture names
	in mind. If you use Dolphin 3.0, this feature should be useless for you.
	
	* ADDED IN v1.1: There's also a new field "subfolder" in the texture generation panel. Unlike
	the "folder" field, subfolder is individual to each dialogue in the file. If you leave this
	field empty, the tool will ignore this field, but if you write something on it, the tool
	will try to create the textures in the path "folder"/"subfolder" (that means you don't have to
	write the "/" at the beginning of the subfolder)
	
	* ADDED IN v1.2: Now, there's a "Grab folder" button on top of the texture name fields. This
	button will prompt you to browse for a folder. Upon selection, the tool will look for textures
	with the format "GRWJD9_<something>_9.png" in said folder and proceed to determine if they
	have white text, gray text, yellow text or none of those. If it recognizes any of the official
	dialogue colours, the name of the file will be put in its corresponding field (current, recent
	or past), otherwise the file will be ignored. 
	
	It's important to note that this function doesn't care about the number of candidate files it finds. 
	If there are two or more "current" dialogue files in the same folder, only the last valid file will 
	be found in the "current" field by the end (the previous file names will have been overwritten),
	so be careful with which files you put together in the same folder.
	
	Internally, this function looks in the position of what would be the first character of the 
	speaker's name in the dialogue (both upper and lower dialogue). I haven't seen yet a dialogue 
	without a speaker's name, but were it to exist, this function wouldn't work.
	
	*ADDED IN v1.3:
 -- Preview Window: When you boot the applet, you will find a second window to the right of the UI.
	As you can see, it's a re-creation of a dialogue scene during the game. The preview window will
	show how the text you're writing in the dialogue will show up finally in the game. This way
	you can make sure that you won't be writting over portraits or outside of the screen with ease.
	The Preview window can be hidden by clicking on its window's close icon or by using the Preview
	toggle button in the Navigation panel.
	
That should cover what you need to know about the usage of this tool. And a lot of reading too.
Now you can go back to Section 0 and see if you understand the quick steps any better.


-----------------------------------------------------------------------------------
4. Tips & tricks.
-----------------------------------------------------------------------------------

 - When in Dolphin, use savestates. Lots.
 - Save often.
 - Don't use the "dump textures" option unless necessary.
 - The dialogue files usually end with "_9.png". They're 1024 x 128 pixels, fat and short, easy to spot.
 - Deleting the textures in the "dump folder" *should* be harmless.
 - Keep at least one of the dumped versions of the dialogues available somewhere, in case you feel like
   correcting something.
 - Stay away from the "-1" button, it doesn't ask if you want to delete that dialogue, it just does it.
 - You can go to the next line using TAB, and go back using SHIFT + TAB.
 - Use different files per chapter. Pre-mission, In-mission, and Post-mission files should be a minimum
   to ensure you keep your sanity.
 - Use folders to organize generated textures.
 - Finding the proper files can be a pain in the ass. Don't despair. Get some rest.


-----------------------------------------------------------------------------------
5. Thanks in no particular order.
-----------------------------------------------------------------------------------

 - To the romhacking.net community, who has made so many cool things.
 - To /m/, who is surprisingly full of nice people such as myself.
 - To Steve, who pointed out this was possible in the first place and is making a menu translation
   for this game (amog others) as well.
 - To Bring Stabity from /m/, for his hard work dumping textures, proposing new features for the applet and
   actively trying new stuff.
 - To Oppai-Missile from /m/ as well, for taking on the role of translator. We all know this is not easy at all.
 - To all those programming communities that have answered my programming doubts ages before I even
   asked about them.
 - To Google. I don't know what would I do without it. Not Java applets, for sure.
 - To you, for reading all of this. Seriously, I think The Lord of the Rings was bearable in comparison.


-----------------------------------------------------------------------------------
6. Contact information.
-----------------------------------------------------------------------------------

I would really prefer if you didn't write to me about this app, as there has to be at least a topic about
this tool in romhacking.net, but if you MUST contact me, send an email to 

ulricvonmesnar@hotmail.com

and make sure you make the subject of the email clear ("[SRW GC Dialogue Editor] Bug report" is an example
of a good subject, "Hello!" is an example of a really bad one).

Please refrain from sending me spam, any kind of virus or stuff like that, as finding my way to
your house to slap your face can prove bothersome.
